# texture.py ~ load up a texture and put it on a box
import pyscene, osg, osgDB
scene = pyscene.pyscene()

texture = osg.Texture2D()
im = osgDB.readImageFile("Images/blueFlowers.png") # comes with osg
if not im :
    raise "Failed to load image file"
texture.setImage(im)

box = osg.Box()
drawable = osg.ShapeDrawable(box)
geode = osg.Geode()

state = drawable.getOrCreateStateSet()
state.setTextureAttributeAndModes(0, texture, osg.StateAttribute.ON)

geode.addDrawable(drawable)
scene.addChild(geode)
scene.run()
